/**
 */
package ram_av.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

import ram_av.InteractionFragment;
import ram_av.Lifeline;
import ram_av.Ram_avPackage;
import ram_av.TemporaryProperty;
import ram_av.TypedElement;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Lifeline</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ram_av.impl.LifelineImpl#getRepresents <em>Represents</em>}</li>
 *   <li>{@link ram_av.impl.LifelineImpl#getLocalProperties <em>Local Properties</em>}</li>
 *   <li>{@link ram_av.impl.LifelineImpl#getCoveredBy <em>Covered By</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class LifelineImpl extends EObjectImpl implements Lifeline
{
  /**
   * The cached value of the '{@link #getRepresents() <em>Represents</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRepresents()
   * @generated
   * @ordered
   */
  protected TypedElement represents;

  /**
   * The cached value of the '{@link #getLocalProperties() <em>Local Properties</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLocalProperties()
   * @generated
   * @ordered
   */
  protected EList<TemporaryProperty> localProperties;

  /**
   * The cached value of the '{@link #getCoveredBy() <em>Covered By</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCoveredBy()
   * @generated
   * @ordered
   */
  protected EList<InteractionFragment> coveredBy;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected LifelineImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Ram_avPackage.Literals.LIFELINE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TypedElement getRepresents()
  {
    if (represents != null && represents.eIsProxy())
    {
      InternalEObject oldRepresents = (InternalEObject)represents;
      represents = (TypedElement)eResolveProxy(oldRepresents);
      if (represents != oldRepresents)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, Ram_avPackage.LIFELINE__REPRESENTS, oldRepresents, represents));
      }
    }
    return represents;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TypedElement basicGetRepresents()
  {
    return represents;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRepresents(TypedElement newRepresents)
  {
    TypedElement oldRepresents = represents;
    represents = newRepresents;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Ram_avPackage.LIFELINE__REPRESENTS, oldRepresents, represents));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<TemporaryProperty> getLocalProperties()
  {
    if (localProperties == null)
    {
      localProperties = new EObjectContainmentEList<TemporaryProperty>(TemporaryProperty.class, this, Ram_avPackage.LIFELINE__LOCAL_PROPERTIES);
    }
    return localProperties;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<InteractionFragment> getCoveredBy()
  {
    if (coveredBy == null)
    {
      coveredBy = new EObjectWithInverseResolvingEList.ManyInverse<InteractionFragment>(InteractionFragment.class, this, Ram_avPackage.LIFELINE__COVERED_BY, Ram_avPackage.INTERACTION_FRAGMENT__COVERED);
    }
    return coveredBy;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Ram_avPackage.LIFELINE__COVERED_BY:
        return ((InternalEList<InternalEObject>)(InternalEList<?>)getCoveredBy()).basicAdd(otherEnd, msgs);
    }
    return super.eInverseAdd(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Ram_avPackage.LIFELINE__LOCAL_PROPERTIES:
        return ((InternalEList<?>)getLocalProperties()).basicRemove(otherEnd, msgs);
      case Ram_avPackage.LIFELINE__COVERED_BY:
        return ((InternalEList<?>)getCoveredBy()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Ram_avPackage.LIFELINE__REPRESENTS:
        if (resolve) return getRepresents();
        return basicGetRepresents();
      case Ram_avPackage.LIFELINE__LOCAL_PROPERTIES:
        return getLocalProperties();
      case Ram_avPackage.LIFELINE__COVERED_BY:
        return getCoveredBy();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Ram_avPackage.LIFELINE__REPRESENTS:
        setRepresents((TypedElement)newValue);
        return;
      case Ram_avPackage.LIFELINE__LOCAL_PROPERTIES:
        getLocalProperties().clear();
        getLocalProperties().addAll((Collection<? extends TemporaryProperty>)newValue);
        return;
      case Ram_avPackage.LIFELINE__COVERED_BY:
        getCoveredBy().clear();
        getCoveredBy().addAll((Collection<? extends InteractionFragment>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Ram_avPackage.LIFELINE__REPRESENTS:
        setRepresents((TypedElement)null);
        return;
      case Ram_avPackage.LIFELINE__LOCAL_PROPERTIES:
        getLocalProperties().clear();
        return;
      case Ram_avPackage.LIFELINE__COVERED_BY:
        getCoveredBy().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Ram_avPackage.LIFELINE__REPRESENTS:
        return represents != null;
      case Ram_avPackage.LIFELINE__LOCAL_PROPERTIES:
        return localProperties != null && !localProperties.isEmpty();
      case Ram_avPackage.LIFELINE__COVERED_BY:
        return coveredBy != null && !coveredBy.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //LifelineImpl
